<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Hoodoo::ActiveRecord::Dated::ClassMethods</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        <h1>
            <span class="type">Module</span>
            Hoodoo::ActiveRecord::Dated::ClassMethods
        </h1>
        <ul class="files">
            <li><a href="../../../../files/lib/hoodoo/active/active_record/dated_rb.html">lib/hoodoo/active/active_record/dated.rb</a></li>
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
    <div class="description">
      
<p>Collection of class methods that get defined on an including class via <a
href="../Dated.html#method-c-included">Hoodoo::ActiveRecord::Dated.included</a>.</p>

    </div>








    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
        <dt>D</dt>
        <dd>
          <ul>
              <li>
                <a href="#method-i-dated">dated</a>,
              </li>
              <li>
                <a href="#method-i-dated_at">dated_at</a>,
              </li>
              <li>
                <a href="#method-i-dated_historical_and_current">dated_historical_and_current</a>,
              </li>
              <li>
                <a href="#method-i-dated_with">dated_with</a>,
              </li>
              <li>
                <a href="#method-i-dated_with_table_name">dated_with_table_name</a>,
              </li>
              <li>
                <a href="#method-i-dating_enabled">dating_enabled</a>,
              </li>
              <li>
                <a href="#method-i-dating_enabled-3F">dating_enabled?</a>
              </li>
          </ul>
        </dd>
        <dt>Q</dt>
        <dd>
          <ul>
              <li>
                <a href="#method-i-quoted_column_name_string">quoted_column_name_string</a>,
              </li>
              <li>
                <a href="#method-i-quoted_column_name_string_for_history">quoted_column_name_string_for_history</a>,
              </li>
              <li>
                <a href="#method-i-quoted_column_names">quoted_column_names</a>
              </li>
          </ul>
        </dd>
    </dl>










    <!-- Methods -->
      <div class="sectiontitle">Instance Public methods</div>
        <div class="method">
          <div class="title method-title" id="method-i-dated">
              <b>dated</b>( context, unquoted_column_names: nil )
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-dated" name="method-i-dated" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Return an ActiveRecord::Relation containing the model instances which are
effective at <code>context.request.dated_at</code>. If this value is nil
the current time in UTC is used.</p>

<p>If historic dating hasn&#39;t been enabled via a call to <a
href="ClassMethods.html#method-i-dating_enabled">dating_enabled</a>, then
the default &#39;all&#39; scope is returned instead.</p>
<dl class="rdoc-list note-list"><dt><code>context</code>
<dd>
<p><a href="../../Services/Context.html">Hoodoo::Services::Context</a>
instance describing a call context. This is typically a value passed to one
of the <a
href="../../Services/Implementation.html">Hoodoo::Services::Implementation</a>
instance methods that a resource subclass implements.</p>
</dd></dl>

<p>Additional <em>named</em> parameters are:</p>
<dl class="rdoc-list note-list"><dt><code>unquoted_column_names</code>
<dd>
<p>(Optional) An Array of Strings giving one or more column names to use for
the query. If omitted, all model attribtues are used as columns. If the
“id” column is not included in the Array, it will be added anyway as this
column is mandatory. The effect is equivalent to an Array given in the <a
href="../../ActiveRecord.html">ActiveRecord</a> <code>select</code> method.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-dated_source')" id="l_method-i-dated_source">show</a>
              </p>
              <div id="method-i-dated_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 212</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">dated</span>( <span class="ruby-identifier">context</span>, <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span> )
  <span class="ruby-identifier">date_time</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">dated_at</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">dated_at</span>( <span class="ruby-identifier">date_time</span>, <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-identifier">unquoted_column_names</span> )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
        <div class="method">
          <div class="title method-title" id="method-i-dated_at">
              <b>dated_at</b>( date_time = Time.now, unquoted_column_names: nil )
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-dated_at" name="method-i-dated_at" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Return an ActiveRecord::Relation scoping a query to include only model
instances that are relevant/effective at the specified date_time.</p>

<p>If historic dating hasn&#39;t been enabled via a call to <a
href="ClassMethods.html#method-i-dating_enabled">dating_enabled</a>, then
the default &#39;all&#39; scope is returned instead.</p>
<dl class="rdoc-list note-list"><dt><code>date_time</code>
<dd>
<p>(Optional) A Time or DateTime instance, or a String that can be converted
to a DateTime instance, for which the “effective dated” scope is to be
constructed.</p>
</dd></dl>

<p>Additional <em>named</em> parameters are:</p>
<dl class="rdoc-list note-list"><dt><code>unquoted_column_names</code>
<dd>
<p>(Optional) An Array of Strings giving one or more column names to use for
the query. If omitted, all model attribtues are used as columns. If the
“id” column is not included in the Array, it will be added anyway as this
column is mandatory. The effect is equivalent to an Array given in the <a
href="../../ActiveRecord.html">ActiveRecord</a> <code>select</code> method.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-dated_at_source')" id="l_method-i-dated_at_source">show</a>
              </p>
              <div id="method-i-dated_at_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 238</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">dated_at</span>( <span class="ruby-identifier">date_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>, <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span> )

  <span class="ruby-identifier">dating_table_name</span> = <span class="ruby-identifier">dated_with_table_name</span>()
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">all</span>() <span class="ruby-keyword">if</span> <span class="ruby-identifier">dating_table_name</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-comment"># &quot;Model.all&quot; -&gt; returns anonymous scope</span>

  <span class="ruby-comment"># Rationalise and convert the date time to UTC.</span>

  <span class="ruby-identifier">date_time</span>      = <span class="ruby-constant">Hoodoo</span><span class="ruby-operator">::</span><span class="ruby-constant">Utilities</span>.<span class="ruby-identifier">rationalise_datetime</span>( <span class="ruby-identifier">date_time</span> ).<span class="ruby-identifier">utc</span>
  <span class="ruby-identifier">safe_date_time</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">sanitize</span>( <span class="ruby-identifier">date_time</span> ) <span class="ruby-comment"># ActiveRecord provides #sanitize</span>

  <span class="ruby-comment"># Create strings that specify the required attributes escaped and</span>
  <span class="ruby-comment"># joined by commas for use in a SQL query, for both main and history</span>
  <span class="ruby-comment"># tables.</span>

  <span class="ruby-identifier">safe_name_string</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">quoted_column_name_string</span>(
    <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-identifier">unquoted_column_names</span>
  )

  <span class="ruby-identifier">safe_history_name_string</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">quoted_column_name_string_for_history</span>(
    <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-identifier">unquoted_column_names</span>
  )

  <span class="ruby-comment"># A query that combines historical and current records which are</span>
  <span class="ruby-comment"># effective at the specified date time.</span>

  <span class="ruby-identifier">nested_query</span> = <span class="ruby-node">%Q{
    (
      SELECT #{ safe_name_string } FROM (
        SELECT #{ safe_name_string },&quot;updated_at&quot; AS &quot;effective_start&quot;,NULL AS &quot;effective_end&quot;
        FROM #{ self.table_name }
        UNION ALL
        SELECT #{ safe_history_name_string },&quot;effective_start&quot;,&quot;effective_end&quot;
        FROM #{ dating_table_name }
      ) AS u
      WHERE &quot;effective_start&quot; &lt;= #{ safe_date_time } AND (&quot;effective_end&quot; &gt; #{ safe_date_time } OR &quot;effective_end&quot; IS NULL)
    ) AS #{ self.table_name }
  }</span>

  <span class="ruby-comment"># Form a query which uses ActiveRecord to list a dated or current</span>
  <span class="ruby-comment"># record.</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">from</span>( <span class="ruby-identifier">nested_query</span> )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
        <div class="method">
          <div class="title method-title" id="method-i-dated_historical_and_current">
              <b>dated_historical_and_current</b>( unquoted_column_names: nil )
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-dated_historical_and_current" name="method-i-dated_historical_and_current" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Return an ActiveRecord::Relation scoping a query that would include all
historical and current model instances.</p>

<p>If historic dating hasn&#39;t been enabled via a call to <a
href="ClassMethods.html#method-i-dating_enabled">dating_enabled</a>, then
the default &#39;all&#39; scope is returned instead.</p>

<p><em>Named</em> parameters are:</p>
<dl class="rdoc-list note-list"><dt><code>unquoted_column_names</code>
<dd>
<p>(Optional) An Array of Strings giving one or more column names to use for
the query. If omitted, all model attribtues are used as columns. If the
“id” column is not included in the Array, it will be added anyway as this
column is mandatory. The effect is equivalent to an Array given in the <a
href="../../ActiveRecord.html">ActiveRecord</a> <code>select</code> method.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-dated_historical_and_current_source')" id="l_method-i-dated_historical_and_current_source">show</a>
              </p>
              <div id="method-i-dated_historical_and_current_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 299</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">dated_historical_and_current</span>( <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span> )

  <span class="ruby-identifier">dating_table_name</span> = <span class="ruby-identifier">dated_with_table_name</span>()
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">all</span>() <span class="ruby-keyword">if</span> <span class="ruby-identifier">dating_table_name</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-comment"># &quot;Model.all&quot; -&gt; returns anonymous scope</span>

  <span class="ruby-comment"># Create strings that specify the required attributes escaped and</span>
  <span class="ruby-comment"># joined by commas for use in a SQL query, for both main and history</span>
  <span class="ruby-comment"># tables.</span>

  <span class="ruby-identifier">safe_name_string</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">quoted_column_name_string</span>(
    <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-identifier">unquoted_column_names</span>
  )

  <span class="ruby-identifier">safe_history_name_string</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">quoted_column_name_string_for_history</span>(
    <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-identifier">unquoted_column_names</span>
  )

  <span class="ruby-comment"># A query that combines historical and current records.</span>

  <span class="ruby-identifier">nested_query</span> = <span class="ruby-node">%Q{
    (
      SELECT #{ safe_name_string }
      FROM #{ self.table_name }
      UNION ALL
      SELECT #{ safe_history_name_string }
      FROM #{ dating_table_name }
    ) AS #{ self.table_name }
  }</span>

  <span class="ruby-comment"># Form a query which uses ActiveRecord to list current and dated</span>
  <span class="ruby-comment"># records.</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">from</span>( <span class="ruby-identifier">nested_query</span> )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
        <div class="method">
          <div class="title method-title" id="method-i-dated_with">
              <b>dated_with</b>()
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-dated_with" name="method-i-dated_with" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Returns the anonymous <a href="../Base.html">ActiveRecord::Base</a>
instance used for this model&#39;s history entries, or <code>nil</code> if
historic dating has not been enabled via a prior call to <a
href="ClassMethods.html#method-i-dating_enabled">dating_enabled</a>.</p>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-dated_with_source')" id="l_method-i-dated_with_source">show</a>
              </p>
              <div id="method-i-dated_with_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 338</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">dated_with</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">nz_co_loyalty_hoodoo_dated_with</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
        <div class="method">
          <div class="title method-title" id="method-i-dated_with_table_name">
              <b>dated_with_table_name</b>()
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-dated_with_table_name" name="method-i-dated_with_table_name" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Get the symbolised name of the history table for model. This defaults to
the name of the model&#39;s table concatenated with
<code>_history_entries</code>. If the table name is <code>:posts</code>,
the history table would be <code>:posts_history_entries</code>.</p>

<p>If historic dating hasn&#39;t been enabled via a call to <a
href="ClassMethods.html#method-i-dating_enabled">dating_enabled</a>,
returns <code>nil</code>.</p>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-dated_with_table_name_source')" id="l_method-i-dated_with_table_name_source">show</a>
              </p>
              <div id="method-i-dated_with_table_name_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 350</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">dated_with_table_name</span>
  <span class="ruby-identifier">instance</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">dated_with</span>()
  <span class="ruby-identifier">instance</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">instance</span>.<span class="ruby-identifier">table_name</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
        <div class="method">
          <div class="title method-title" id="method-i-dating_enabled">
              <b>dating_enabled</b>( history_table_name: self.table_name + &#39;_history_entries&#39; )
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-dating_enabled" name="method-i-dating_enabled" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Activate historic dating for this model.</p>

<p>See the module documentation for <a
href="../Dated.html">Hoodoo::ActiveRecord::Dated</a> for full information
on dating, table requirements, default table names and so forth.</p>

<p><strong>Named</strong> parameters are:</p>
<dl class="rdoc-list note-list"><dt><code>history_table_name</code>
<dd>
<p>Optional String or Symbol name of the table which stores the history
entries for this model. If omitted, defaults to the value described by the
documentation for <a href="../Dated.html">Hoodoo::ActiveRecord::Dated</a>.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-dating_enabled_source')" id="l_method-i-dating_enabled_source">show</a>
              </p>
              <div id="method-i-dating_enabled_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 166</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">dating_enabled</span>( <span class="ruby-identifier">history_table_name</span><span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">table_name</span> <span class="ruby-operator">+</span> <span class="ruby-string">&#39;_history_entries&#39;</span> )

  <span class="ruby-comment"># Define an anonymous model for the history entries.</span>

  <span class="ruby-identifier">history_klass</span> = <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span>( <span class="ruby-operator">::</span><span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span> ) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">primary_key</span> = <span class="ruby-value">:id</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">table_name</span>  = <span class="ruby-identifier">history_table_name</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># Record the anonymous model class in a namespaced class attribute</span>
  <span class="ruby-comment"># for reference in the rest of the dating code via #dated_with().</span>

  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">nz_co_loyalty_hoodoo_dated_with</span> = <span class="ruby-identifier">history_klass</span>

<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
        <div class="method">
          <div class="title method-title" id="method-i-dating_enabled-3F">
              <b>dating_enabled?</b>()
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-dating_enabled-3F" name="method-i-dating_enabled-3F" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>If a prior call has been made to <a
href="ClassMethods.html#method-i-dating_enabled">dating_enabled</a> then
this method returns <code>true</code>, else <code>false</code>.</p>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-dating_enabled-3F_source')" id="l_method-i-dating_enabled-3F_source">show</a>
              </p>
              <div id="method-i-dating_enabled-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 185</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">dating_enabled?</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">dated_with</span>().<span class="ruby-identifier">present?</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
      <div class="sectiontitle">Instance Protected methods</div>
        <div class="method">
          <div class="title method-title" id="method-i-quoted_column_name_string">
              <b>quoted_column_name_string</b>( unquoted_column_names: nil )
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-quoted_column_name_string" name="method-i-quoted_column_name_string" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Returns a String of comma-separated sanitised (quoted) column names based
on this model&#39;s attribute names, or the given array of unquoted column
names.</p>

<p><em>Named</em> parameters are:</p>
<dl class="rdoc-list note-list"><dt><code>unquoted_column_names</code>
<dd>
<p>Optional Array of unquoted column names to use. Must contain only Strings.
If column “id” is missing, it will be added for you.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-quoted_column_name_string_source')" id="l_method-i-quoted_column_name_string_source">show</a>
              </p>
              <div id="method-i-quoted_column_name_string_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 379</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quoted_column_name_string</span>( <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span> )
  <span class="ruby-identifier">unquoted_column_names</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">attribute_names</span>()
  <span class="ruby-identifier">unquoted_column_names</span>   = <span class="ruby-identifier">unquoted_column_names</span> <span class="ruby-operator">+</span> [ <span class="ruby-string">&#39;id&#39;</span> ] <span class="ruby-keyword">unless</span> <span class="ruby-identifier">unquoted_column_names</span>.<span class="ruby-identifier">include?</span>( <span class="ruby-string">&#39;id&#39;</span> )

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">quoted_column_names</span>( <span class="ruby-identifier">unquoted_column_names</span> ).<span class="ruby-identifier">join</span>( <span class="ruby-string">&#39;,&#39;</span> )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
        <div class="method">
          <div class="title method-title" id="method-i-quoted_column_name_string_for_history">
              <b>quoted_column_name_string_for_history</b>( unquoted_column_names: nil )
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-quoted_column_name_string_for_history" name="method-i-quoted_column_name_string_for_history" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>As ::quoted_column_name_string, but returns a String appropriate for the
history table. Notably, this requires a source column of “uuid” to be
mapped in as column name “id” and works on the assumption that the primary
key is “id”.</p>

<p><em>Named</em> parameters are:</p>
<dl class="rdoc-list note-list"><dt><code>unquoted_column_names</code>
<dd>
<p>Optional Array of unquoted column names to use. Must contain only Strings.
If column “id” is missing, it will be added for you.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-quoted_column_name_string_for_history_source')" id="l_method-i-quoted_column_name_string_for_history_source">show</a>
              </p>
              <div id="method-i-quoted_column_name_string_for_history_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 397</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quoted_column_name_string_for_history</span>( <span class="ruby-identifier">unquoted_column_names</span><span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span> )
  <span class="ruby-identifier">unquoted_column_names</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">attribute_names</span>
  <span class="ruby-identifier">primary_key_index</span>       = <span class="ruby-identifier">unquoted_column_names</span>.<span class="ruby-identifier">index</span>( <span class="ruby-string">&#39;id&#39;</span> )

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">primary_key_index</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">unquoted_column_names</span> = <span class="ruby-identifier">unquoted_column_names</span> <span class="ruby-operator">+</span> [ <span class="ruby-string">&#39;id&#39;</span> ]
    <span class="ruby-identifier">primary_key_index</span>     = <span class="ruby-identifier">unquoted_column_names</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">-</span> <span class="ruby-number">1</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">quoted_column_names</span>     = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">quoted_column_names</span>( <span class="ruby-identifier">unquoted_column_names</span> )
  <span class="ruby-identifier">quoted_primary_key_name</span> = <span class="ruby-identifier">quoted_column_names</span>[ <span class="ruby-identifier">primary_key_index</span> ]
  <span class="ruby-identifier">history_primary_key</span>     = <span class="ruby-string">&#39;&quot;uuid&quot; AS &#39;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">quoted_primary_key_name</span>

  <span class="ruby-identifier">quoted_column_names</span>[ <span class="ruby-identifier">primary_key_index</span> ] = <span class="ruby-identifier">history_primary_key</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">quoted_column_names</span>.<span class="ruby-identifier">join</span>( <span class="ruby-string">&#39;,&#39;</span> )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
        <div class="method">
          <div class="title method-title" id="method-i-quoted_column_names">
              <b>quoted_column_names</b>( unquoted_column_names )
            <a href="../../../../classes/Hoodoo/ActiveRecord/Dated/ClassMethods.html#method-i-quoted_column_names" name="method-i-quoted_column_names" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Takes an Array of unquoted column names and returns a new Array of names
quoted by the current database adapter.</p>
<dl class="rdoc-list note-list"><dt><code>unquoted_column_names</code>
<dd>
<p>Optional Array of unquoted column names to use. Must contain only Strings.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-quoted_column_names_source')" id="l_method-i-quoted_column_names_source">show</a>
              </p>
              <div id="method-i-quoted_column_names_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/active/active_record/dated.rb, line 363</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quoted_column_names</span>( <span class="ruby-identifier">unquoted_column_names</span> )
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">unquoted_column_names</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">|</span>
    <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">quote_column_name</span>( <span class="ruby-identifier">c</span> )
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
</div>

    </div>
  </body>
</html>
